//
//  MallOrderManageViewController.m
//  CYWFrame
//
//  Created by Macx on 2017/9/8.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "MallOrderManageViewController.h"

#import "MallOrderContentViewController.h"
#import "SearchViewController.h"

@interface MallOrderManageViewController ()

@end

@implementation MallOrderManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self buildUI];
}


#pragma mark ==========构建UI==========
- (void)buildUI {
    
    self.view.backgroundColor = kWhiteColor;
    
    self.navigationItem.title = @"订单管理";
    
    // 导航栏左右按钮
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"index_search_white"] style:UIBarButtonItemStylePlain target:self action:@selector(orderSearchClicK:)];
    
    
    // keyword 关键词，匹配商品名或订单号(order_no) status 订单状态 unpaid(未支付),paid(已支付),delivered(已发货),received(已收货),cancel(取消) page 页码，默认为1 per_page 每页显示数，默认为10 orderby 排序字段 create_time（下单时间，默认） direction 排序方式 desc（降序，默认）asc（升序）
    
    NSArray *arr = @[@"unpaid", @"paid", @"delivered", @"received"];
    NSArray *nameArr = @[@"待付款", @"已付款", @"已发货", @"已完成"];
    NSMutableArray *vcArr = [[NSMutableArray alloc] init];
    for (int i = 0; i < arr.count; i++) {
        MallOrderContentViewController *vc = [[MallOrderContentViewController alloc] init];
        vc.statusStr = arr[i];
        [vcArr addObject:vc];
    }
    _segment = [CCZSegementController2 segementControllerWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) titles:nameArr];
    [_segment setSegementViewControllers:vcArr];
    
    _segment.style = CCZSegementStyleDefault;
    [_segment setSegementTintColor:UIMainColorRGB];
    [self.view addSubview:_segment.view];
    [self addChildViewController:_segment];
    
    [_segment selectedNavAtIndex:^(NSInteger index) {
        NSLog(@"index %ld",index);
        
//        NSNotification *notification =[NSNotification notificationWithName:@"reloadMall" object:nil userInfo:nil];
//        //通过通知中心发送通知
//        [[NSNotificationCenter defaultCenter] postNotification:notification];
        
    }];
    [_segment setSelectedItemAtIndex:self.defaultIndex];

    
    
}

#pragma mark ==========响应方法===========
- (void)orderSearchClicK:(id)sender {
    NSLog(@"点击搜索");
    SearchViewController *searchVC = [[SearchViewController alloc] init];
    searchVC.type = 4;
    [self.navigationController pushViewController:searchVC animated:YES];
}
                                             

// 懒加载

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
